<!DOCTYPE html>
<html lang="zh">
<head>
  <!-- 元数据 -->
  <meta charset="utf-8">
  <link rel="icon" href="/blog/images/favicon.ico">
  <title>输入输出流 | YongKJ</title>
  <meta name="author" content="yongkj" />
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="robots" content="index,follow" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <meta name="format-detection" content="telphone=no, email=no" />
  
    
      <meta name="description" itemprop="description" content="Pursue excellence and success will follow." />
    
  
  <meta name="description" content="基本概念 Java对数据的操作是通过流的方式，IO流用来处理设备之间的数据传输，上传文件和下载文件，Java用于操作流的对象都在IO包中。  IO流的分类 字节流 字节流基类  ​      1）InputStream  InputStream：字节输入流基类，抽象类是表示字节输入流的所有类的超类。  12345678910111213&#x2F;&#x2F; 从输入流中读取数据的下一个字节abstract int">
<meta property="og:type" content="article">
<meta property="og:title" content="输入输出流">
<meta property="og:url" content="https://yongkj.gitee.io/blog/2021/02/09/java-io-stream/index.html">
<meta property="og:site_name" content="YongKJ">
<meta property="og:description" content="基本概念 Java对数据的操作是通过流的方式，IO流用来处理设备之间的数据传输，上传文件和下载文件，Java用于操作流的对象都在IO包中。  IO流的分类 字节流 字节流基类  ​      1）InputStream  InputStream：字节输入流基类，抽象类是表示字节输入流的所有类的超类。  12345678910111213&#x2F;&#x2F; 从输入流中读取数据的下一个字节abstract int">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://yongkj.gitee.io/blog/2021/02/09/java-io-stream/wallhaven-369362.jpg">
<meta property="article:published_time" content="2021-02-09T13:07:52.000Z">
<meta property="article:modified_time" content="2021-02-10T07:59:14.842Z">
<meta property="article:author" content="yongkj">
<meta property="article:tag" content="创建">
<meta property="article:tag" content="传输">
<meta property="article:tag" content="读取">
<meta property="article:tag" content="输出">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://yongkj.gitee.io/blog/2021/02/09/java-io-stream/wallhaven-369362.jpg">
<meta name="twitter:site" content="@Candiinya">
  <link rel="alternate" href="atom.xml" type="application/atom+xml">
  <!-- 站点验证相关 -->
  
    
    
    
  
  <!-- 样式表文件 -->
  <link rel="stylesheet" id="kratos-css" href="/blog/css/kratosr.min.css" type="text/css" media="all">
  <link rel="stylesheet" id="highlight-css" href="/blog/css/highlight.min.css" type="text/css" media="all">
  <link rel="stylesheet" id="fontawe-css" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" type="text/css" media="all">
  <link rel="stylesheet" id="nprogress-css" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.css" type="text/css" media="all">
  
  
  
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css">
  
  
    <link rel="stylesheet" id="darkmode-css" href="/blog/css/kr-dark.min.css" type="text/css" media="all">
  
  <!-- 不得不预先加载的一些JS文件 -->
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
  
    <script src="https://cdn.jsdelivr.net/npm/qrcode_js@1.0.0/qrcode.min.js"></script>
  
  
<meta name="generator" content="Hexo 5.2.0"></head>


    <body class="custom-background">
        <div id="kratos-wrapper">
    <div id="kratos-page">
        <div id="kratos-header">
            <div class="nav-toggle"><a class="kratos-nav-toggle js-kratos-nav-toggle"><i></i></a></div>
            <header id="kratos-header-section">
                <div class="container">
                    <div class="nav-header">
                        <div class="color-logo"><a href="/blog/">YongKJ</a></div>
                        <nav id="kratos-menu-wrap">
                            <ul id="kratos-primary-menu" class="sf-menu">
                            
                            
                                <li><a href="/blog/"><i class="fa fa-home"></i>首页</a></li>
                            
                            
                            
                                <li><a href="/blog/archives/"><i class="fa fa-file"></i>档案馆</a></li>
                            
                            
                            
                                <li>
                                <a><i class="fa fa-link"></i>链接</a>
                                <ul class="sub-menu">
                                    
                                    
                                    
                                    
                                        <li><a target="_blank" rel="noopener" href="http://software.yongkj.cn/software/">软件俱乐部</a></li>
                                    
                                    
                                    
                                        <li><a target="_blank" rel="noopener" href="http://pocketyun.yongkj.cn/">袖珍网盘吧</a></li>
                                    
                                    
                                    
                                        <li><a target="_blank" rel="noopener" href="http://study.yongkj.cn/">英语随身学</a></li>
                                    
                                    
                                </ul>
                                </li>
                            
                            
                            
                                <li><a href="/blog/atom.xml"><i class="fa fa-rss"></i>RSS 订阅</a></li>
                            
                            
                            
                                <li><a href="/blog/about/"><i class="fa fa-paper-plane"></i>关于我</a></li>
                            
                            
                            </ul>
                        </nav>
                    </div>
                </div>
            </header>
        </div>
        <div class="kratos-start kratos-hero-2">
            <!-- <div class="kratos-overlay"></div> -->
            <div class="kratos-cover kratos-cover-2 text-center">
                <div class="desc desc2 animate-box">
                    <a href="/blog/"><h2>YongKJ</h2><br><span>勇往直前，永不言弃</span></a>
                </div>
            </div>
        </div>

        <div id="kratos-blog-post">
            <div class="container">
                    <div class="row">
                        
        <div id="main">
            <section class="col-md-8">
    <article>
        <div class="kratos-hentry kratos-post-inner clearfix">
            <header class="kratos-entry-header">
                <h1 class="kratos-entry-title text-center">输入输出流</h1>
                
                <div class="kratos-post-meta text-center">
                    <span>
                        <i class="fa fa-calendar"></i> 2021-02-09
                        <i class="fa fa-folder"></i> 分类于 <a class="label-link" href="/blog/categories/Java%E5%AD%A6%E4%B9%A0/">Java学习</a>
                        <i class="fa fa-user"></i> 作者 yongkj
                        <i class="fa fa-edit"></i> 
                        
                        
                            ~7.74K
                        
                        字
                        
                    </span>
                </div>
            </header>
            <div class="kratos-post-content">
                
                    <div class="kratos-post-inner-toc">
                        <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5"><span class="toc-number">1.</span> <span class="toc-text">基本概念</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#IO%E6%B5%81%E7%9A%84%E5%88%86%E7%B1%BB"><span class="toc-number">2.</span> <span class="toc-text">IO流的分类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AD%97%E8%8A%82%E6%B5%81"><span class="toc-number">3.</span> <span class="toc-text">字节流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AD%97%E7%AC%A6%E6%B5%81"><span class="toc-number">4.</span> <span class="toc-text">字符流</span></a></li></ol>
                    </div>
                
                <hr />
                <h3 id="基本概念"><a href="#基本概念" class="headerlink" title="基本概念"></a>基本概念</h3><ol>
<li>Java对数据的操作是通过流的方式，IO流用来处理设备之间的数据传输，上传文件和下载文件，Java用于操作流的对象都在IO包中。</li>
</ol>
<h3 id="IO流的分类"><a href="#IO流的分类" class="headerlink" title="IO流的分类"></a>IO流的分类</h3><p><img src="http://file.yongkj.cn/fileSystem/admin/My%20Learning%20Material/%E9%9D%A2%E8%AF%95%E8%B5%84%E6%96%99/%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA%E6%B5%81/20160522165107051.jpg" alt="20160522165107051.jpg"></p>
<h3 id="字节流"><a href="#字节流" class="headerlink" title="字节流"></a>字节流</h3><ol>
<li>字节流基类</li>
</ol>
<p>​      1）InputStream</p>
<blockquote>
<p>InputStream：字节输入流基类，抽象类是表示字节输入流的所有类的超类。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 从输入流中读取数据的下一个字节</span></span><br><span class="line"><span class="function"><span class="keyword">abstract</span> <span class="keyword">int</span> <span class="title">read</span><span class="params">()</span></span></span><br><span class="line"><span class="function"><span class="comment">// 从输入流中读取一定数量的字节，并将其存储在缓冲区数组 b中</span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">read</span><span class="params">(<span class="keyword">byte</span>[] b)</span></span></span><br><span class="line"><span class="function"><span class="comment">// 将输入流中最多 len 个数据字节读入 byte 数组</span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">read</span><span class="params">(<span class="keyword">byte</span>[] b, <span class="keyword">int</span> off, <span class="keyword">int</span> len)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function"><span class="comment">// 跳过和丢弃此输入流中数据的 n个字节</span></span></span><br><span class="line"><span class="function"><span class="keyword">long</span> <span class="title">skip</span><span class="params">(<span class="keyword">long</span> n)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function"><span class="comment">// 关闭此输入流并释放与该流关联的所有系统资源</span></span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">close</span><span class="params">()</span></span></span><br></pre></td></tr></table></figure>

<p>​      2）OutputStream</p>
<blockquote>
<p>OutputStream：字节输出流基类，抽象类是表示输出字节流的所有类的超类。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 将 b.length 个字节从指定的 byte 数组写入此输出流</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">write</span><span class="params">(<span class="keyword">byte</span>[] b)</span></span></span><br><span class="line"><span class="function"><span class="comment">// 将指定 byte 数组中从偏移量 off 开始的 len 个字节写入此输出流</span></span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">write</span><span class="params">(<span class="keyword">byte</span>[] b, <span class="keyword">int</span> off, <span class="keyword">int</span> len)</span></span></span><br><span class="line"><span class="function"><span class="comment">// 将指定的字节写入此输出流</span></span></span><br><span class="line"><span class="function"><span class="keyword">abstract</span> <span class="keyword">void</span> <span class="title">write</span><span class="params">(<span class="keyword">int</span> b)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function"><span class="comment">// 关闭此输出流并释放与此流有关的所有系统资源</span></span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">close</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function"><span class="comment">// 刷新此输出流并强制写出所有缓冲的输出字节</span></span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">flush</span><span class="params">()</span></span></span><br></pre></td></tr></table></figure>

<ol start="2">
<li>字节文件操作流</li>
</ol>
<p>​      1）FileInputStream</p>
<blockquote>
<p>FileInputStream：字节文件输入流，从文件系统中的某个文件中获得输入字节，用于读取诸如图像数据之类的原始字节流。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//构造方法：</span></span><br><span class="line">    <span class="comment">// 通过打开一个到实际文件的连接来创建一个FileInputStream，该文件通过文件系统中的File对象file指定</span></span><br><span class="line">    FileInputStream(File file)</span><br><span class="line">    <span class="comment">// 通过打开一个到实际文件的连接来创建一个FileInputStream，该文件通过文件系统中的路径name指定</span></span><br><span class="line">    FileInputStream(String name)</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 读取f盘下该文件f://hell/test.txt</span></span><br><span class="line">        <span class="comment">//构造方法1</span></span><br><span class="line">        InputStream inputStream = <span class="keyword">new</span> FileInputStream(<span class="keyword">new</span> File(<span class="string">&quot;f://hello//test.txt&quot;</span>));</span><br><span class="line">        <span class="keyword">int</span> i = <span class="number">0</span>;</span><br><span class="line">        <span class="comment">//一次读取一个字节</span></span><br><span class="line">        <span class="keyword">while</span> ((i = inputStream.read()) != -<span class="number">1</span>) &#123;</span><br><span class="line"></span><br><span class="line">            <span class="comment">// System.out.print(i + &quot; &quot;);// 65 66 67 68</span></span><br><span class="line">            <span class="comment">//为什么会输出65 66 67 68？因为字符在底层存储的时候就是存储的数值。即字符对应的ASCII码。</span></span><br><span class="line">            System.out.print((<span class="keyword">char</span>) i + <span class="string">&quot; &quot;</span>);<span class="comment">// A B C D</span></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//关闭IO流</span></span><br><span class="line">        inputStream.close();</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 读取f盘下该文件f://hell/test.txt</span></span><br><span class="line">        <span class="comment">//构造方法2</span></span><br><span class="line">        InputStream inputStream2 = <span class="keyword">new</span> FileInputStream(<span class="string">&quot;f://hello/test.txt&quot;</span>);</span><br><span class="line">        <span class="comment">// 字节数组</span></span><br><span class="line">        <span class="keyword">byte</span>[] b = <span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">2</span>];</span><br><span class="line">        <span class="keyword">int</span> i2 = <span class="number">0</span>;</span><br><span class="line">        <span class="comment">//  一次读取一个字节数组</span></span><br><span class="line">        <span class="keyword">while</span> ((i2 = inputStream2.read(b)) != -<span class="number">1</span>) &#123;</span><br><span class="line"></span><br><span class="line">            System.out.print(<span class="keyword">new</span> String(b, <span class="number">0</span>, i2) + <span class="string">&quot; &quot;</span>);<span class="comment">// AB CD</span></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//关闭IO流</span></span><br><span class="line">        inputStream2.close();</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注： 一次读取一个字节数组，提高了操作效率,IO流使用完毕一定要关闭。</p>
</blockquote>
<p>​      2）FileOutputStream</p>
<blockquote>
<p>FileOutputStream：字节文件输出流是用于将数据写入到File，从程序中写入到其他位置。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//构造方法：</span></span><br><span class="line">    <span class="comment">// 创建一个向指定File对象表示的文件中写入数据的文件输出流</span></span><br><span class="line">    FileOutputStream(File file)</span><br><span class="line">    <span class="comment">// 创建一个向指定File对象表示的文件中写入数据的文件输出流</span></span><br><span class="line">    FileOutputStream(File file, <span class="keyword">boolean</span> append)</span><br><span class="line">    <span class="comment">// 创建一个向具有指定名称的文件中写入数据的输出文件流</span></span><br><span class="line">    FileOutputStream(String name)</span><br><span class="line">    <span class="comment">// 创建一个向具有指定name的文件中写入数据的输出文件流</span></span><br><span class="line">    FileOutputStream(String name, <span class="keyword">boolean</span> append)</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">OutputStream outputStream = <span class="keyword">new</span> FileOutputStream(<span class="keyword">new</span> File(<span class="string">&quot;test.txt&quot;</span>));</span><br><span class="line"><span class="comment">// 写出数据</span></span><br><span class="line">outputStream.write(<span class="string">&quot;ABCD&quot;</span>.getBytes());</span><br><span class="line"><span class="comment">// 关闭IO流</span></span><br><span class="line">outputStream.close();</span><br><span class="line"></span><br><span class="line"><span class="comment">// 内容追加写入</span></span><br><span class="line">OutputStream outputStream2 = <span class="keyword">new</span> FileOutputStream(<span class="string">&quot;test.txt&quot;</span>, <span class="keyword">true</span>);</span><br><span class="line"><span class="comment">// 输出换行符</span></span><br><span class="line">outputStream2.write(<span class="string">&quot;\r\n&quot;</span>.getBytes());</span><br><span class="line"><span class="comment">// 输出追加内容</span></span><br><span class="line">outputStream2.write(<span class="string">&quot;hello&quot;</span>.getBytes());</span><br><span class="line"><span class="comment">// 关闭IO流</span></span><br><span class="line">outputStream2.close();</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注；输出的目的地文件不存在，则会自动创建，不指定盘符的话，默认创建在项目目录下;输出换行符时一定要写\r\n不能只写\n,因为不同文本编辑器对换行符的识别存在差异性。</p>
</blockquote>
<ol start="3">
<li>字节缓冲流（高效流）</li>
</ol>
<p>​      1）BufferedInputStream</p>
<blockquote>
<p>BufferedInputStream：字节缓冲输入流，提高了读取效率。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//构造方法：</span></span><br><span class="line">     <span class="comment">// 创建一个 BufferedInputStream并保存其参数，即输入流in，以便将来使用。</span></span><br><span class="line">     BufferedInputStream(InputStream in)</span><br><span class="line">     <span class="comment">// 创建具有指定缓冲区大小的 BufferedInputStream并保存其参数，即输入流in以便将来使用</span></span><br><span class="line">     BufferedInputStream(InputStream in, <span class="keyword">int</span> size)</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">InputStream in = <span class="keyword">new</span> FileInputStream(<span class="string">&quot;test.txt&quot;</span>);</span><br><span class="line"><span class="comment">// 字节缓存流</span></span><br><span class="line">BufferedInputStream bis = <span class="keyword">new</span> BufferedInputStream(in);</span><br><span class="line"><span class="keyword">byte</span>[] bs = <span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">20</span>];</span><br><span class="line"><span class="keyword">int</span> len = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">while</span> ((len = bis.read(bs)) != -<span class="number">1</span>) &#123;</span><br><span class="line"></span><br><span class="line">    System.out.print(<span class="keyword">new</span> String(bs, <span class="number">0</span>, len));</span><br><span class="line">    <span class="comment">// ABCD</span></span><br><span class="line">    <span class="comment">// hello</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 关闭流</span></span><br><span class="line">bis.close();</span><br></pre></td></tr></table></figure>

<p>​      2）BufferedOutputStream</p>
<blockquote>
<p>BufferedOutputStream：字节缓冲输出流，提高了写出效率。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//构造方法：</span></span><br><span class="line">     <span class="comment">// 创建一个新的缓冲输出流，以将数据写入指定的底层输出流</span></span><br><span class="line">     BufferedOutputStream(OutputStream out)</span><br><span class="line">     <span class="comment">// 创建一个新的缓冲输出流，以将具有指定缓冲区大小的数据写入指定的底层输出流</span></span><br><span class="line">     BufferedOutputStream(OutputStream out, <span class="keyword">int</span> size)</span><br><span class="line"></span><br><span class="line">     常用方法：</span><br><span class="line">     <span class="comment">// 将指定 byte 数组中从偏移量 off 开始的 len 个字节写入此缓冲的输出流</span></span><br><span class="line">     <span class="function"><span class="keyword">void</span> <span class="title">write</span><span class="params">(<span class="keyword">byte</span>[] b, <span class="keyword">int</span> off, <span class="keyword">int</span> len)</span></span></span><br><span class="line"><span class="function">     <span class="comment">// 将指定的字节写入此缓冲的输出流</span></span></span><br><span class="line"><span class="function">     <span class="keyword">void</span> <span class="title">write</span><span class="params">(<span class="keyword">int</span> b)</span></span></span><br><span class="line"><span class="function">     <span class="comment">// 刷新此缓冲的输出流</span></span></span><br><span class="line"><span class="function">     <span class="keyword">void</span> <span class="title">flush</span><span class="params">()</span></span></span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">BufferedOutputStream bos = <span class="keyword">new</span> BufferedOutputStream(<span class="keyword">new</span> FileOutputStream(<span class="string">&quot;test.txt&quot;</span>, <span class="keyword">true</span>));</span><br><span class="line"><span class="comment">// 输出换行符</span></span><br><span class="line">bos.write(<span class="string">&quot;\r\n&quot;</span>.getBytes());</span><br><span class="line"><span class="comment">// 输出内容</span></span><br><span class="line">bos.write(<span class="string">&quot;Hello Android&quot;</span>.getBytes());</span><br><span class="line"><span class="comment">// 刷新此缓冲的输出流</span></span><br><span class="line">bos.flush();</span><br><span class="line"><span class="comment">// 关闭流</span></span><br><span class="line">bos.close();</span><br></pre></td></tr></table></figure>

<h3 id="字符流"><a href="#字符流" class="headerlink" title="字符流"></a>字符流</h3><ol>
<li>字符流基类</li>
</ol>
<p>​      1）Reader</p>
<blockquote>
<p>Reader:读取字符流的抽象类</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//常用方法：</span></span><br><span class="line">    <span class="comment">// 读取单个字符</span></span><br><span class="line">    <span class="function"><span class="keyword">int</span> <span class="title">read</span><span class="params">()</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 将字符读入数组</span></span></span><br><span class="line"><span class="function">    <span class="keyword">int</span> <span class="title">read</span><span class="params">(<span class="keyword">char</span>[] cbuf)</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 将字符读入数组的某一部分</span></span></span><br><span class="line"><span class="function">    <span class="keyword">abstract</span> <span class="keyword">int</span> <span class="title">read</span><span class="params">(<span class="keyword">char</span>[] cbuf, <span class="keyword">int</span> off, <span class="keyword">int</span> len)</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 跳过字符</span></span></span><br><span class="line"><span class="function">    <span class="keyword">long</span> <span class="title">skip</span><span class="params">(<span class="keyword">long</span> n)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function">    <span class="comment">// 关闭该流并释放与之关联的所有资源</span></span></span><br><span class="line"><span class="function">    <span class="keyword">abstract</span> <span class="keyword">void</span> <span class="title">close</span><span class="params">()</span></span></span><br></pre></td></tr></table></figure>

<p>​      2）Writer</p>
<blockquote>
<p>Writer:写入字符流的抽象类.</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//常用方法：</span></span><br><span class="line">    <span class="comment">// 写入字符数组</span></span><br><span class="line">     <span class="function"><span class="keyword">void</span> <span class="title">write</span><span class="params">(<span class="keyword">char</span>[] cbuf)</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 写入字符数组的某一部分</span></span></span><br><span class="line"><span class="function">    <span class="keyword">abstract</span> <span class="keyword">void</span> <span class="title">write</span><span class="params">(<span class="keyword">char</span>[] cbuf, <span class="keyword">int</span> off, <span class="keyword">int</span> len)</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 写入单个字符</span></span></span><br><span class="line"><span class="function">    <span class="keyword">void</span> <span class="title">write</span><span class="params">(<span class="keyword">int</span> c)</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 写入字符串</span></span></span><br><span class="line"><span class="function">    <span class="keyword">void</span> <span class="title">write</span><span class="params">(String str)</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 写入字符串的某一部分</span></span></span><br><span class="line"><span class="function">    <span class="keyword">void</span> <span class="title">write</span><span class="params">(String str, <span class="keyword">int</span> off, <span class="keyword">int</span> len)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function">    <span class="comment">// 将指定字符添加到此 writer</span></span></span><br><span class="line"><span class="function">    Writer <span class="title">append</span><span class="params">(<span class="keyword">char</span> c)</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 将指定字符序列添加到此 writer</span></span></span><br><span class="line"><span class="function">    Writer <span class="title">append</span><span class="params">(CharSequence csq)</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 将指定字符序列的子序列添加到此 writer.Appendable</span></span></span><br><span class="line"><span class="function">    Writer <span class="title">append</span><span class="params">(CharSequence csq, <span class="keyword">int</span> start, <span class="keyword">int</span> end)</span></span></span><br><span class="line"><span class="function"></span></span><br><span class="line"><span class="function">    <span class="comment">// 关闭此流，但要先刷新它</span></span></span><br><span class="line"><span class="function">    <span class="keyword">abstract</span> <span class="keyword">void</span> <span class="title">close</span><span class="params">()</span></span></span><br><span class="line"><span class="function">    <span class="comment">// 刷新该流的缓冲</span></span></span><br><span class="line"><span class="function">    <span class="keyword">abstract</span> <span class="keyword">void</span> <span class="title">flush</span><span class="params">()</span></span></span><br></pre></td></tr></table></figure>

<ol start="2">
<li>字符转换流</li>
</ol>
<p>​      1）InputStreamReader</p>
<blockquote>
<p>InputStreamReader：字节流转字符流，它使用的字符集可以由名称指定或显式给定，否则将接受平台默认的字符集。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//构造方法：</span></span><br><span class="line">    <span class="comment">// 创建一个使用默认字符集的 InputStreamReader</span></span><br><span class="line">    InputStreamReader(InputStream in)</span><br><span class="line">    <span class="comment">// 创建使用给定字符集的 InputStreamReader</span></span><br><span class="line">    InputStreamReader(InputStream in, Charset cs)</span><br><span class="line">    <span class="comment">// 创建使用给定字符集解码器的 InputStreamReader</span></span><br><span class="line">    InputStreamReader(InputStream in, CharsetDecoder dec)</span><br><span class="line">    <span class="comment">// 创建使用指定字符集的 InputStreamReader</span></span><br><span class="line">    InputStreamReader(InputStream in, String charsetName)</span><br><span class="line"> <span class="comment">//特有方法：</span></span><br><span class="line">    <span class="comment">//返回此流使用的字符编码的名称 </span></span><br><span class="line">    <span class="function">String <span class="title">getEncoding</span><span class="params">()</span> </span></span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//使用默认编码        </span></span><br><span class="line">      InputStreamReader reader = <span class="keyword">new</span> InputStreamReader(<span class="keyword">new</span> FileInputStream(<span class="string">&quot;test.txt&quot;</span>));</span><br><span class="line">      <span class="keyword">int</span> len;</span><br><span class="line">      <span class="keyword">while</span> ((len = reader.read()) != -<span class="number">1</span>) &#123;</span><br><span class="line">          System.out.print((<span class="keyword">char</span>) len);<span class="comment">//爱生活，爱Android</span></span><br><span class="line"></span><br><span class="line">      &#125;</span><br><span class="line">      reader.close();</span><br><span class="line"></span><br><span class="line">       <span class="comment">//指定编码 </span></span><br><span class="line">      InputStreamReader reader = <span class="keyword">new</span> InputStreamReader(<span class="keyword">new</span> FileInputStream(<span class="string">&quot;test.txt&quot;</span>),<span class="string">&quot;utf-8&quot;</span>);</span><br><span class="line">      <span class="keyword">int</span> len;</span><br><span class="line">      <span class="keyword">while</span> ((len = reader.read()) != -<span class="number">1</span>) &#123;</span><br><span class="line">          System.out.print((<span class="keyword">char</span>) len);<span class="comment">//????????Android</span></span><br><span class="line">      &#125;</span><br><span class="line">      reader.close();</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注：Eclipse默认使用GBK编码,test.txt文件所以是GBK编码，当指定utf-8编码时所以会乱码。</p>
</blockquote>
<p>​      2）OutputStreamWriter</p>
<blockquote>
<p>OutputStreamWriter：字节流转字符流。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//构造方法：</span></span><br><span class="line">    <span class="comment">// 创建使用默认字符编码的 OutputStreamWriter</span></span><br><span class="line">    OutputStreamWriter(OutputStream out)</span><br><span class="line">    <span class="comment">// 创建使用给定字符集的 OutputStreamWriter</span></span><br><span class="line">    OutputStreamWriter(OutputStream out, Charset cs)</span><br><span class="line">    <span class="comment">// 创建使用给定字符集编码器的 OutputStreamWriter</span></span><br><span class="line">    OutputStreamWriter(OutputStream out, CharsetEncoder enc)</span><br><span class="line">    <span class="comment">// 创建使用指定字符集的 OutputStreamWriter</span></span><br><span class="line">    OutputStreamWriter(OutputStream out, String charsetName)</span><br><span class="line"> <span class="comment">//特有方法：</span></span><br><span class="line">    <span class="comment">//返回此流使用的字符编码的名称 </span></span><br><span class="line">    <span class="function">String <span class="title">getEncoding</span><span class="params">()</span> </span></span><br></pre></td></tr></table></figure>

<ol start="3">
<li>字符缓冲流（高效流）</li>
</ol>
<p>​      1）BufferedReader</p>
<blockquote>
<p>BufferedReader：字符缓冲流，从字符输入流中读取文本，缓冲各个字符，从而实现字符、数组和行的高效读取。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//构造方法：</span></span><br><span class="line">    <span class="comment">// 创建一个使用默认大小输入缓冲区的缓冲字符输入流</span></span><br><span class="line">    BufferedReader(Reader in)</span><br><span class="line">    <span class="comment">// 创建一个使用指定大小输入缓冲区的缓冲字符输入流</span></span><br><span class="line">    BufferedReader(Reader in, <span class="keyword">int</span> sz)</span><br><span class="line"> <span class="comment">//特有方法：</span></span><br><span class="line">    <span class="comment">// 读取一个文本行</span></span><br><span class="line">    <span class="function">String <span class="title">readLine</span><span class="params">()</span></span></span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//生成字符缓冲流对象</span></span><br><span class="line">BufferedReader reader = <span class="keyword">new</span> BufferedReader(<span class="keyword">new</span> InputStreamReader(<span class="keyword">new</span> FileInputStream(<span class="string">&quot;test.txt&quot;</span>)));</span><br><span class="line">String str;</span><br><span class="line"><span class="comment">//一次性读取一行</span></span><br><span class="line"><span class="keyword">while</span> ((str = reader.readLine()) != <span class="keyword">null</span>) &#123;</span><br><span class="line">    System.out.println(str);<span class="comment">// 爱生活，爱Android</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//关闭流</span></span><br><span class="line">reader.close();</span><br></pre></td></tr></table></figure>

<p>​      2）BufferedWriter</p>
<blockquote>
<p>BufferedWriter：字符缓冲流，将文本写入字符输出流，缓冲各个字符，从而提供单个字符、数组和字符串的高效写入。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//构造方法：</span></span><br><span class="line">    <span class="comment">// 创建一个使用默认大小输出缓冲区的缓冲字符输出流</span></span><br><span class="line">    BufferedWriter(Writer out)</span><br><span class="line">    <span class="comment">// 创建一个使用给定大小输出缓冲区的新缓冲字符输出流</span></span><br><span class="line">    BufferedWriter(Writer out, <span class="keyword">int</span> sz)</span><br><span class="line"> <span class="comment">//特有方法：</span></span><br><span class="line">    <span class="comment">// 写入一个行分隔符</span></span><br><span class="line">    <span class="function"><span class="keyword">void</span> <span class="title">newLine</span><span class="params">()</span> </span></span><br></pre></td></tr></table></figure>

<ol start="4">
<li>FileReader、FileWriter</li>
</ol>
<p>​      1）FileReader：InputStreamReader类的直接子类，用来读取字符文件的便捷类，使用默认字符编码。<br>​      2）FileWriter：OutputStreamWriter类的直接子类，用来写入字符文件的便捷类，使用默认字符编码。</p>

            </div>
            
                <div class="kratos-copyright text-center clearfix">
                    <h5>本作品采用 <a rel="license nofollow" target="_blank" href="http://creativecommons.org/licenses/by-sa/4.0/">知识共享署名-相同方式共享 4.0 国际许可协议</a> 进行许可</h5>
                </div>
            
            <footer class="kratos-entry-footer clearfix">
                
                    <div class="post-like-donate text-center clearfix" id="post-like-donate">
                    
                    
                        <a class="share" href="javascript:;"><i class="fa fa-share-alt"></i> 分享</a>
                        <div class="share-wrap" style="display: none;">
    <div class="share-group">
        <a href="javascript:;" class="share-plain qq" onclick="share('qq');" rel="nofollow">
            <div class="icon-wrap">
                <i class="fa fa-qq"></i>
            </div>
        </a>
        <a href="javascript:;" class="share-plain qzone" onclick="share('qzone');" rel="nofollow">
            <div class="icon-wrap">
                <i class="fa fa-star"></i>
            </div>
        </a>
        <a href="javascript:;" class="share-plain weixin pop style-plain" rel="nofollow">
            <div class="icon-wrap">
                <i class="fa fa-weixin"></i>
            </div>
            <div class="share-int">
                <div class="qrcode" id="wechat-qr"></div>
                <p>打开微信“扫一扫”，打开网页后点击屏幕右上角分享按钮</p>
            </div>
        </a>
        <a href="javascript:;" class="share-plain weibo" onclick="share('weibo');" rel="nofollow">
            <div class="icon-wrap">
                <i class="fa fa-weibo"></i>
            </div>
        </a>
        <a href="javascript:;" class="share-plain facebook style-plain" onclick="share('facebook');" rel="nofollow">
            <div class="icon-wrap">
                <i class="fa fa-facebook"></i>
            </div>
        </a>
        <a href="javascript:;" class="share-plain twitter style-plain" onclick="share('twitter');" rel="nofollow">
            <div class="icon-wrap">
                <i class="fa fa-twitter"></i>
            </div>
        </a>
    </div>
    <script type="text/javascript">
        $(()=>{
            new QRCode("wechat-qr", {
                text: "https://yongkj.gitee.io/blog/2021/02/09/java-io-stream/",
                width: 150,
                height: 150,
                correctLevel : QRCode.CorrectLevel.H
            });
        });
        function share(dest) {
            const qqBase        = "https://connect.qq.com/widget/shareqq/index.html?";
            const weiboBase     = "https://service.weibo.com/share/share.php?";
            const qzoneBase     = "https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?";
            const facebookBase  = "https://www.facebook.com/sharer/sharer.php?";
            const twitterBase   = "https://twitter.com/intent/tweet?";
            const hostUrl       = "https://yongkj.gitee.io/blog/2021/02/09/java-io-stream/";
            const title         = "「输入输出流」";
            const excerpt       = `基本概念
Java对数据的操作是通过流的方式，IO流用来处理设备之间的数据传输，上传文件和下载文件，Java用于操作流的对象都在IO包中。

IO流的分类
字节流
字节流基类

​      1）InputStream

InputS...`;
            let _URL;
            switch (dest) {
                case "qq"       : _URL = qqBase+"url="+hostUrl+"&title="+title+"&desc=&summary="+excerpt+"&site=cxpy";     break;
                case "weibo"    : _URL = weiboBase+"url="+hostUrl+"&title="+title+excerpt;                                 break;
                case "qzone"    : _URL = qzoneBase+"url="+hostUrl+"&title="+title+"&desc=&summary="+excerpt+"&site=cxpy";  break;
                case "facebook" : _URL = facebookBase+"u="+hostUrl;                                                        break;
                case "twitter"  : _URL = twitterBase+"text="+title+excerpt+"&url="+hostUrl;                                break;
            }
            window.open(_URL);
        };
    </script>
</div>
                    
                    </div>
                
                <div class="footer-tag clearfix">
                    <div class="pull-left">
                    <i class="fa fa-tags"></i>
                        <a class="tag-none-link" href="/blog/tags/%E4%BC%A0%E8%BE%93/" rel="tag">传输</a>, <a class="tag-none-link" href="/blog/tags/%E5%88%9B%E5%BB%BA/" rel="tag">创建</a>, <a class="tag-none-link" href="/blog/tags/%E8%AF%BB%E5%8F%96/" rel="tag">读取</a>, <a class="tag-none-link" href="/blog/tags/%E8%BE%93%E5%87%BA/" rel="tag">输出</a>
                    </div>
                    <div class="pull-date">
                    <span>最后编辑：2021-02-10</span>
                    </div>
                </div>
            </footer>
        </div>
        
            <nav class="navigation post-navigation clearfix" role="navigation">
                
                <div class="nav-previous clearfix">
                    <a title=" 类加载" href="/blog/2021/02/08/java-class-loading/">&lt; 上一篇</a>
                </div>
                
                
                <div class="nav-next clearfix">
                    <a title=" 控制反转与依赖注入" href="/blog/2021/02/12/java-ioc-di/">下一篇 &gt;</a>
                </div>
                
            </nav>
        
        
    </article>
</section>
        </div>
                
            <section id="kratos-widget-area" class="col-md-4 hidden-xs hidden-sm">
                
                    <aside id="krw-about" class="widget widget-kratos-about clearfix">
    
    <div class="photo-background"></div>
    <div class="photo-wrapper clearfix">
        <div class="photo-wrapper-tip text-center">
            <img class="about-photo" src="/blog/images/avatar.webp" />
        </div>
    </div>
    <div class="textwidget">
        
            <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5"><span class="toc-number">1.</span> <span class="toc-text">基本概念</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#IO%E6%B5%81%E7%9A%84%E5%88%86%E7%B1%BB"><span class="toc-number">2.</span> <span class="toc-text">IO流的分类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AD%97%E8%8A%82%E6%B5%81"><span class="toc-number">3.</span> <span class="toc-text">字节流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AD%97%E7%AC%A6%E6%B5%81"><span class="toc-number">4.</span> <span class="toc-text">字符流</span></a></li></ol>
        
    </div>
</aside>
                
                    <!-- Moved to about.ejs -->
                
                    
  <aside id="krw-categories" class="widget widget-categories clearfix">
    <h4 class="widget-title"><i class="fa fa-folder"></i>分类目录</h4>
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/blog/categories/Java%E5%AD%A6%E4%B9%A0/">Java学习</a><span class="category-list-count">16</span></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E7%AC%AC%E4%B8%80%E6%AC%A1/">第一次</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E8%8B%B1%E8%AF%AD%E5%AD%A6%E4%B9%A0/">英语学习</a><span class="category-list-count">8</span></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E9%9F%B3%E4%B9%90%E7%A9%BA%E9%97%B4/">音乐空间</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E9%A1%B9%E7%9B%AE%E7%BB%8F%E5%8E%86/">项目经历</a><span class="category-list-count">3</span></li></ul>
  </aside>


                
                    
  <aside id="krw-tags" class="widget widget-kratos-tags clearfix">
    <h4 class="widget-title"><i class="fa fa-tags"></i>标签聚合</h4>
      <div class="tag-clouds">
        <a href="/blog/tags/apility/" style="font-size: 0.6em;">apility</a> <a href="/blog/tags/bus/" style="font-size: 0.6em;">bus</a> <a href="/blog/tags/city/" style="font-size: 0.6em;">city</a> <a href="/blog/tags/comfort/" style="font-size: 0.6em;">comfort</a> <a href="/blog/tags/communication/" style="font-size: 0.6em;">communication</a> <a href="/blog/tags/contribute/" style="font-size: 0.6em;">contribute</a> <a href="/blog/tags/convenient/" style="font-size: 0.6em;">convenient</a> <a href="/blog/tags/develop/" style="font-size: 0.6em;">develop</a> <a href="/blog/tags/education/" style="font-size: 0.6em;">education</a> <a href="/blog/tags/enhance/" style="font-size: 0.6em;">enhance</a> <a href="/blog/tags/facility/" style="font-size: 0.6em;">facility</a> <a href="/blog/tags/flight/" style="font-size: 0.6em;">flight</a> <a href="/blog/tags/foreign/" style="font-size: 0.6em;">foreign</a> <a href="/blog/tags/free/" style="font-size: 0.6em;">free</a> <a href="/blog/tags/hello/" style="font-size: 0.6em;">hello</a> <a href="/blog/tags/improve/" style="font-size: 0.8em;">improve</a> <a href="/blog/tags/information/" style="font-size: 0.6em;">information</a> <a href="/blog/tags/invest/" style="font-size: 0.6em;">invest</a>
      </div>
  </aside>

                
                    
  <aside id="krw-posts" class="widget widget-kratos-poststab">
  <h4 class="widget-title"><i class="fa fa-file"></i>最新文章</h4>
  <div class="tab-content">
      <ul class="list-group">
        
        
          
          
            <a class="list-group-item" href="/blog/2021/02/12/java-dynamic-proxy/"><i class="fa  fa-book"></i> 动态代理</a>
            
          
        
          
          
            <a class="list-group-item" href="/blog/2021/02/12/java-constructor/"><i class="fa  fa-book"></i> 构造器的注入与使用</a>
            
          
        
          
          
            <a class="list-group-item" href="/blog/2021/02/12/java-ioc-di/"><i class="fa  fa-book"></i> 控制反转与依赖注入</a>
            
          
        
          
          
            <a class="list-group-item" href="/blog/2021/02/09/java-io-stream/"><i class="fa  fa-book"></i> 输入输出流</a>
            
          
        
          
          
            <a class="list-group-item" href="/blog/2021/02/08/java-class-loading/"><i class="fa  fa-book"></i> 类加载</a>
            
          
        
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
          
            
      </ul>
  </div>
  </aside>

                
            </section>
        
        </div>
    </div>
</div>
<footer>
    <div id="footer">
        <div class="kr-tool text-center">
            <div class="tool">
                
                    <div class="box search-box">
                        <a href="/blog/search/">
                            <span class="fa fa-search"></span>
                        </a>
                    </div>
                
                
                    <div class="box theme-box" id="darkmode-switch">
                        <span class="fa fa-adjust"></span>
                    </div>
                
                
            </div>
            <div class="box gotop-box">
                <span class="fa fa-chevron-up"></span>
            </div>
        </div>
        <div class="container">
            <div class="row">
                <div class="col-md-6 col-md-offset-3 footer-list text-center">
                    <ul class="kratos-social-icons">
                        
                        
                        <li><a target="_blank" rel="nofollow" href="https://t.me/CandyUnion"><i class="fa fa-telegram"></i></a></li>
                        <li><a target="_blank" rel="nofollow" href="https://twitter.com/Candiinya"><i class="fa fa-twitter"></i></a></li>
                        
                        
                        
                        <li><a target="_blank" rel="nofollow" href="https://github.com/yongkj"><i class="fa fa-github"></i></a></li>
                        <li><a target="_blank" rel="nofollow" href="/blog/atom.xml"><i class="fa fa-rss"></i></a></li>
                    </ul>
                    <ul class="kratos-copyright">
                        <div>
                            <li>&copy; 2021 yongkj 版权所有.</li>
                            <li>本站已运行<span id="span_dt">Loading...</span></li>
                        </div>
                        <div>
                            <li>Theme <a href="https://github.com/Candinya/Kratos-Rebirth" target="_blank">Kratos:Rebirth</a></li>
                            <li>Made with&nbsp;<i class="fa fa-heart throb" style="color:#d43f57"></i>&nbsp;by <a href="https://candinya.com" target="_blank" rel="nofollow">Candinya</a>.</li>
                        </div>
                        <div>
                            <li>Powered by <a href="https://hexo.io" target="_blank" rel="nofollow">Hexo</a></li>
                            <li>Hosted on <a href="https://www.yongkj.cn" target="_blank">勇往直前</a></li>
                        </div>
                        <div>
                            
                            
                        </div>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</footer>
</div>
</div>

        <script defer src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.4/dist/js/bootstrap.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.js"></script>
<script>const notMobile = (!(navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)));</script>

    <div>
        <canvas id="snow"></canvas>
        <script async type="text/javascript" src="/blog/js/snow.min.js"></script>
    </div>

<script async src="/blog/js/candy.min.js"></script>


    <script defer src="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>

<script defer src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script>
<script defer src="/blog/js/kratosr.min.js"></script>
<script defer src="/blog/js/pjax.min.js"></script>


    <script defer src="/blog/js/kr-dark.min.js"></script>



    </body>
</html>